package com.springbootbase.springbootproject.service.impl;

import com.springbootbase.springbootproject.mapper.UserMapper;
import com.springbootbase.springbootproject.pojo.User;
import com.springbootbase.springbootproject.service.UserService;
import com.springbootbase.springbootproject.utils.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper ;
    @Override
    public User findByUserName(String username, String userType) {
        User u = userMapper.findByUserName(username,userType);
        return u;
    }

    @Override
    public void register(String username, String password, String userType) {
        String md5String = Md5Util.getMD5String(password);
        userMapper.add(username,md5String,userType);
    }

    @Override
    public void update(Long id,String username, String email, String phone) {
        userMapper.updateName(id,username);
        userMapper.updatePhone(id,phone,email);
    }

}
